package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqNewSheetDetail;
import com.ruoyi.hqfinance.domain.HqNewSheetRebate;
import com.ruoyi.hqfinance.domain.vo.HqNewSheetRebateByDayVo;
import com.ruoyi.hqfinance.domain.vo.HqNewSheetRebateByMonthVo;
import com.ruoyi.hqfinance.mapper.HqNewSheetDetailMapper;
import com.ruoyi.hqfinance.mapper.HqNewSheetRebateMapper;
import com.ruoyi.hqfinance.service.HqNewSheetRebateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class HqNewSheetRebateServiceImpl implements HqNewSheetRebateService {
    @Autowired
    private HqNewSheetRebateMapper hqNewSheetRebateMapper;
    @Autowired
    private HqNewSheetDetailMapper hqNewSheetDetailMapper;
    @Override
    public List<HqNewSheetRebate> collect(HqNewSheetRebateByDayVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqNewSheetRebate> rebates = hqNewSheetRebateMapper.collect(vo);
        assert rebates != null;
        for (HqNewSheetRebate hqNewSheetRebate : rebates){
            hqNewSheetRebate.setDestination("全网");
            if (vo.getCollectType() == 2){
                hqNewSheetRebate.setCollectDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return rebates;
    }

}
